﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MINERP.CustomerManage.StartOrder
{
    public partial class FrmSetUser : Form
    {
        //属性
        public Form frm;
        public int UserId;
        public List<MODEL.CustomerManage.StartOrder.User> FilterUser;
        public FrmSetUser()
        {
            InitializeComponent();
        }

        private void FrmSetUser_Load(object sender, EventArgs e)
        {
            cbUser.DisplayMember = "UserName";
            cbUser.ValueMember = "UserId";
            cbUser.DataSource = FilterUser;
            cbUser.SelectedValue = UserId;
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                int userId = Convert.ToInt32(cbUser.SelectedValue);
                if (frm is FrmStartOrder)
                {
                    ((FrmStartOrder)frm).SelectedUserId = userId;
                    ((FrmStartOrder)frm).SelectedUserName = cbUser.Text.Trim();
                }
                else
                {
                    ((FrmEditOrder)frm).SelectedUserId = userId;
                    ((FrmEditOrder)frm).SelectedUserName = cbUser.Text.Trim();
                }
                DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "确认", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            try
            {
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "确认", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
    }
}
